package com.iweb.user.controller;

import com.iweb.user.model.Show;
import com.iweb.user.model.Seat; // 导入 Seat
import com.iweb.user.model.Ticket;
import com.iweb.user.service.UserSeatService; // 导入 UserSeatService
import com.iweb.user.service.UserShowsService;
import com.iweb.user.service.UserTicketService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;

@RestController
@RequestMapping("/api")
@CrossOrigin
public class ShowController {

    @Autowired
    private UserShowsService userShowsService;

    @Autowired
    private UserTicketService userTicketService;

    @Autowired
    private UserSeatService userSeatService;

    @GetMapping("/shows")
    public List<Show> getAllShows() {
        return userShowsService.selectAllShows();
    }

    @GetMapping("/shows/{showId}")
    public Show getShowById(@PathVariable int showId) {
        return userShowsService.selectShowById(showId);
    }

    @GetMapping("/shows/{showId}/tickets")
    public List<Ticket> getTicketsByShowId(@PathVariable int showId) {
        return userTicketService.findTicketsByShowId(showId);
    }

    @GetMapping("/shows/{showId}/seats")
    public List<Seat> getSeatsByShowId(@PathVariable int showId) {
        return userSeatService.findSeatsByShowId(showId);
    }
}